<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>私人直播间</title>
    <link rel="icon" href="./favicon.ico">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css">
    <script src="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/flv.js@latest"></script>
    <style>
        body {
            background-image: url('./bj1.jpg'); /* 全局背景图 */
            background-size: cover;
            margin: 0;
            height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            font-family: 'Arial', sans-serif;
            color: #E6E6FA;
        }
        .video-title {
            font-size: 1.2em;
            text-align: center;
            margin-bottom: 20px;
        }
        #dplayer-container {
            width: 70%;
            max-width: 100%;
            height: auto;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-bottom: 20px;
        }
        @media screen and (max-width: 768px) {
            #dplayer-container {
                width: 100%;
            }
        }
        #dplayer {
            width: 100%;
            border-radius: 10px;
            overflow: hidden;
            border: 2px solid black;
            box-shadow: 0 0 15px 10px rgba(255, 255, 255, 0.5);
        }
        .buttons-container {
            display: flex;
            justify-content: space-around;
            width: 70%;
            margin: 0 auto;
        }
        .button {
            width: 150px;
            height: 40px;
            background: linear-gradient(to right, #b19cd9, #7e76c8);
            border: 2px solid #7e76c8;
            border-radius: 5px;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-weight: bold;
            text-decoration: none;
            margin: 0 10px;
            transition: all 0.3s ease;
        }
        .button:hover {
            background: linear-gradient(to right, #7e76c8, #b19cd9);
            border-color: #b19cd9;
        }
        .announcement {
            position: fixed;
            top: 0;
            width: 100%;
            background: rgba(185, 156, 217, 0.3);
            padding: 10px;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
            border: 0px solid transparent;
            border-image: linear-gradient(to right, rgba(185, 156, 217, 0.99), rgba(185, 156, 217, 0)) 1;
            border-image-slice: 1;
            color: #E6E6FA;
            text-align: center;
            font-size: 1.2em;
            white-space: nowrap;
            overflow: hidden;
        }
        .announcement marquee {
            width: 100%;
        }

        .volume-control {
            margin-top: 20px;
            width: 70%;
            max-width: 400px;
            display: flex;
            align-items: center;
            justify-content: flex-start;
        }
        .volume-control label {
            margin-right: 10px;
            color: #E6E6FA;
            font-size: 1em;
            white-space: nowrap;
        }
        .volume-control input[type="range"] {
            -webkit-appearance: none;
            width: 100%;
            height: 8px;
            background: rgba(255, 255, 255, 0.3);
            border-radius: 5px;
            outline: none;
            opacity: 0.7;
            transition: opacity 0.2s;
        }
        .volume-control input[type="range"]:hover {
            opacity: 1;
        }
        .volume-control input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 16px;
            height: 16px;
            background: #E6E6FA;
            border-radius: 50%;
            cursor: pointer;
            transition: background 0.2s;
        }
        .volume-control input[type="range"]::-webkit-slider-thumb:hover {
            background: #b19cd9;
        }
        .volume-control input[type="range"]::-moz-range-thumb {
            width: 16px;
            height: 16px;
            background: #E6E6FA;
            border-radius: 50%;
            cursor: pointer;
            transition: background 0.2s;
        }
        .volume-control input[type="range"]::-moz-range-thumb:hover {
            background: #b19cd9;
        }

        .footer {
            position: fixed;
            bottom: 10px;
            text-align: center;
            width: 100%;
            color: #E6E6FA;
            font-size: 0.9em;
        }
        .footer a {
            color: #E6E6FA;
            text-decoration: none;
            transition: color 0.3s ease;
        }
        .footer a:hover {
            color: #b19cd9;
        }

        @media (max-width: 600px) {
            .buttons-container {
                flex-direction: column;
                align-items: center;
            }

            .button {
                width: 120px;
                height: 30px;
                margin: 5px 0;
            }

            #dplayer {
                border-radius: 4px;
            }

            .volume-control {
                width: 90%;
            }

            .footer {
                font-size: 0.8em;
            }
        }
    </style>
</head>
<body>
    <div class="announcement">
        <marquee behavior="scroll" direction="left" scrollamount="5">好无聊，来陪我看电视吧。</marquee>
    </div>
    <h1 class="video-title">私人直播间</h1>
    <div id="dplayer-container">
        <div id="dplayer"></div>
    </div>
    <div class="volume-control">
        <label for="volume-slider">音量</label>
        <input type="range" id="volume-slider" min="0" max="1" step="0.01" value="0">
    </div>

    <!-- 版权链接 -->
    <div class="footer">
        2025 & <a href="https://emohe.cn" target="_blank">阿涛的小破站</a>
    </div>

    <script>
        const dp = new DPlayer({
            container: document.getElementById('dplayer'),
            theme: '#E6E6FA',
            autoplay: true,
            mutex: false,
            hotkey: true,
            volume: 0,
            video: {
                url: '/liveapi/live/movie.flv',
                type: 'flv',
                pic: './bf1.jpg', /* 播放器背景图 */
            },
            p2pConfig: {
                live: true
            }
        });

        const volumeSlider = document.getElementById('volume-slider');

        volumeSlider.addEventListener('input', (event) => {
            const volume = parseFloat(event.target.value);
            dp.volume(volume);
        });

        volumeSlider.value = dp.volume();

        const playerContainer = document.getElementById('dplayer-container');
        dp.on('fullscreen', () => {
            if (window.screen.orientation && window.screen.orientation.lock) {
                window.screen.orientation.lock('landscape')
                    .then(() => {
                        console.log('屏幕已锁定为横向模式');
                    })
                    .catch((error) => {
                        console.warn('无法锁定屏幕方向，请手动旋转设备:', error);
                    });
            } else {
                console.warn('当前浏览器不支持锁定屏幕方向，请手动旋转设备。');
            }
        });

        dp.on('fullscreen_cancel', () => {
            if (window.screen.orientation && window.screen.orientation.unlock) {
                window.screen.orientation.unlock();
            }
        });
    </script>
</body>
</html>